var express = require('express');
var multer = require('multer')
var router = express.Router();
var upload = multer({ dest: './public/images' });


const  Admin  = require('../control/admin')


/* GET users listing. */
router.get('/', async function (req, res, next) {
   let result = await Admin.Reg(req);
   res.send(result)
});

router.post('/file', upload.single('avatar', 2), function (req, res, next) {
  res.send(req.file.filename)
})


router.post('/isLogin', async function (req, res, next) {
  let result = await Admin.isLogin(req);
  
  res.send(result)
})
router.post('/AddClassName', async function (req, res, next) {
  let result = await Admin.AddClassName(req);
  res.send(result)
})
router.post('/ClassName', async function (req, res, next) {
  let result = await Admin.ClassName(req);
  res.send(result)
})
router.post('/DelClass', async function (req, res, next) {
  let result = await Admin.DelClass(req);
  res.send(result)
})
router.post('/ClassAddStudents', async function (req, res, next) {
  let result = await Admin.ClassAddStudents(req);
  res.send(result)
})
router.post('/getStudent', async function (req, res, next) {
  let result = await Admin.getStudent();
  res.send(result)
})
router.post('/AddStudents', async function (req, res, next) {
  let result = await Admin.AddStudents(req);
  res.send(result)
})
router.post('/DelStudent', async function (req, res, next) {
  let result = await Admin.DelStudent(req);
  res.send(result)
})
router.post('/QueryStudens', async function (req, res, next) {
  let result = await Admin.QueryStudens(req);
  res.send(result)
})
router.post('/AddClassStudents', async function (req, res, next) {
  let result = await Admin.AddClassStudents(req);
  res.send(result)
})
router.post('/ReadStudents', async function (req, res, next) {
  let result = await Admin.ReadStudents(req);
  res.send(result)
})

router.get('/login', async function (req, res, next) {
   let result = await Admin.Login(req);
   console.log(result)
   res.send(result)
});


module.exports = router;
